/*
 * Configuration.java
 *
 * Created on November 17, 2003, 6:07 PM
 */

package gov.nist.applet.phone.ua;

import gov.nist.applet.phone.ua.gui.ServerInfoXmlManager;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

import com.dtec.common.util.EncryptionUtil;
import com.dtec.common.util.SettingUtil;
import com.dtec.resource.settingInfo.Account;
import com.dtec.resource.settingInfo.AdvanceSettings;

/**
 * This class represents the configuration of the user agent
 * 
 * @author DERUELLE Jean
 */
public class Configuration {
	// Stack:
	public static long latency4VoiceMessaging = 5000;
	public String name;
	public String password;
	public String stackName;
	public String stackIPAddress;
	public String contactIPAddress;
	public String outboundProxy="172.16.200.187";
	public int proxyPort=5060;
	public int listeningPort=31312;
	public String signalingTransport="udp";
	public String mediaTransport="udp";
	public String retransmissionFilter;
	public String httpBusy;
	public String userURI="109@"+outboundProxy;
	public Map map;
	public ServerInfoXmlManager serverInfoManager;
	public String path;
	public static AdvanceSettings advanceSettings;

	public Configuration(Account account) {
		stackName = "Jain-Sip-Meeting-User-Agent";
		path = "xmlSource/ServerInfo.xml";
		//系统设置
		advanceSettings=SettingUtil.getAdvanceSettings(SettingUtil.advanceSettingsPath);
		if(advanceSettings!=null){
			//产生Key
			if(advanceSettings.getEncryptionEnable().equals("1")){
				EncryptionUtil.start();
			}
		}
		
		try {
			stackIPAddress = InetAddress.getLocalHost().getHostAddress();
			contactIPAddress = stackIPAddress;
		} catch (UnknownHostException uhe) {
			uhe.printStackTrace();
		}
		retransmissionFilter = "false";
		if (account != null) {
			outboundProxy = account.getProxyaddress();
			proxyPort = Integer.parseInt(account.getProxyport());
			signalingTransport = account.getProtocal();
			mediaTransport = account.getProtocal();
			name = account.getName();
			password = account.getPassword();
			listeningPort = new java.util.Random().nextInt(8975) + 1024;
			System.out.println();
			userURI = name + "@" + outboundProxy;
			System.out.println(userURI);
		}
		httpBusy = "http://www.google.com";
	}

}
